<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center personalData_flex_0_higd"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub personalData_fd0_0_higd'>
					<view class='flex flex-wrap align-center personalData_fd0_0_c0_higd' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  personalData_fd0_0_c0_c0_higd'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='personalData_fd0_0_c1_c0_higd'>{{$t('个人资料')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end personalData_fd0_0_c0_higd'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

			<view class="flex flex-direction flex-wrap align-stretch personalData_flex_1_higd">
				<view class='flex flex-wrap align-center personalData_fd1_0_higd'>
					<text class='personalData_fd1_0_c0_higd'>{{$t('头像')}}</text>
					<benben-image-upload :path.sync="user.avatar" :img-id.sync="header_img" :is-cropping="true"
						:is-show-clean="false" class="upload position-relative personalData_fd1_0_c1_higd">

						<image class=" personalData_fd1_0_c1_image_higd" mode="aspectFill"
							:src="user.avatar ? user.avatar : STATIC_URL+'80.png'"></image>
					</benben-image-upload>
					<!-- <image class='personalData_fd1_0_c2_higd' mode="aspectFit" :src='STATIC_URL+"11.png"'></image> -->
				</view>
				<view class='flex flex-wrap align-center justify-between personalData_fd1_1_higd'>
					<text class='personalData_fd1_0_c0_higd'>{{$t('姓名')}}</text>
					<benben-input class='flex-sub personalData_fd1_1_c1_higd' type="text" :placeholder="$t('请输入昵称')"
						confirm-type="done" :maxlength="7" placeholder-style="color:#666666;font-size:32rpx"
						v-model="group==1?user.real_name:user.nickname" />
				</view>
				<button class='personalData_fd1_2_higd' @tap.stop="submitsFunc()">{{$t('保存')}}</button>
			</view>


			<!--选择性别开始 -->
			<benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1701938799488" :label.sync='sex'
				:value.sync='xb' :options='sex_options' mode='selector' :mask-show='true' :timeout='true'
				:picker-height='88' default-type='value' :default-props='{"label":"name","value":"value"}'>
				<template #picker-header>
					<view class='flex flex-wrap align-center justify-between personalData_picker2_0_higd'>
						<text class='personalData_picker2_0_c0_higd'
							@tap="$refs.benbenWritePickerCodepicker2.cancel()">{{$t('取消')}}</text>
						<text class='personalData_picker2_0_c1_higd'>{{$t('选择性别')}}</text>
						<text class='personalData_picker2_0_c2_higd'
							@tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">{{$t('确认')}}</text>
					</view>
				</template>
			</benben-picker>
			<!--选择性别结束 -->
			<!---flex布局2flex布局开始-->
			<view class="flex benben-flex-layout flex-wrap align-center personalData_flex_3_higd">
				<view class='flex flex-wrap align-center justify-between personalData_fd3_0_higd'
					@tap.stop="pickerDiy1701938799488=true">
					<text class='personalData_fd3_0_c0_higd'>{{$t('性别')}}</text>
					<view class='flex flex-wrap align-center'>
						<text class='personalData_fd3_0_c1_c0_higd' v-if=" sex==''">{{$t('请选择性别')}}</text><text
							class='personalData_fd3_0_c1_c0_1_higd' v-if=" sex!=''">{{sex}}</text>
						<image class='personalData_fd3_0_c1_c1_higd' mode="aspectFit" :src='STATIC_URL+"11.png"'>
						</image>
					</view>
				</view>
				<!-- 	<view class='flex flex-wrap align-center justify-between personalData_fd3_1_higd'>
					<text class='personalData_fd3_0_c0_higd'>{{$t('年龄')}}</text>
					<text class='personalData_fd3_1_c1_higd'>{{user.age}}</text>
				</view> -->
				<view class='flex flex-wrap align-center justify-between personalData_fd3_1_higd' v-if="user.name">
					<text class='personalData_fd3_0_c0_higd'>{{$t('教职工号')}}</text>
					<text class='personalData_fd3_1_c1_higd'>{{user.name}}</text>
				</view>
				<view class='flex flex-wrap align-center justify-between personalData_fd3_1_higd' v-if="(user.xq_name||csinfo.tgxxxjcxxxqjbxx_xqmc)">
					<text class='personalData_fd3_0_c0_higd'>{{$t('校区')}}</text>
					<text class='personalData_fd3_1_c1_higd'>{{group==1?user.xq_name:csinfo.tgxxxjcxxxqjbxx_xqmc}}</text>
				</view>
				<view class='flex flex-wrap align-center justify-between personalData_fd3_1_higd'>
					<text class='personalData_fd3_0_c0_higd'>{{$t('手机号')}}</text>
					<text class='personalData_fd3_1_c1_higd'>{{user.mobile}}</text>
				</view>
			</view>

			<!---flex布局2flex布局结束-->


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import { host } from '@/common/config.js';

	export default {
		components: {},


		data() {
			return {
				csinfo: {
					tgxxxjcxxxqjbxx_xqmc:''
				},
				"pickerDiy1701938799488": false,
				/** xq_name【校区】
				 *   age【年龄】
				 *   is_close【是否开启签到】
				 *   follow_count【关注的店铺数量】
				 *   is_pay_password【是否设置支付密码 1 已设置 0 未设置】
				 *   certified【实名认证状态 -1 未进行认证 1 待审核 2 审核通过 3 已拒绝】
				 *   total_money【会员总金额】
				 *   browse_count【足迹数量】
				 *   collection_count【收藏数量】
				 *   _mobile【手机号不带*号】
				 *   score【积分余额】
				 *   total_consumption_money【总消费金额】
				 *   freeze_money【会员冻结金额】
				 *   user_money【会员余额】
				 *   gender【性别 1 男 2 女】
				 *   birthday【生日】
				 *   email【邮箱】
				 *   account【登录账号】
				 *   avatar【头像】
				 *   real_name【昵称】
				 *   mobile【手机号带*号】
				 *   userlevel_id【会员级别】
				 *   id【会员ID】
				 *   tags【标签】
				 *   hobby【爱好】
				 *   address_code【地址编码】
				 *   address【地址】
				 *   invite_code【邀请码】 **/
				"user": {
					xq_name:'',
					"invite_code": "",
					"address": "",
					"address_code": "",
					"hobby": "",
					"tags": "",
					"id": "",
					"userlevel_id": "",
					"mobile": "",
					"real_name": "",
					"avatar": "",
					"account": "",
					"email": "",
					"birthday": "",
					"gender": "",
					"create_time": "",
					"user_money": "",
					"freeze_money": "",
					"total_consumption_money": "",
					"score": "",
					"_mobile": "",
					"coupon": "",
					"collection_count": "",
					"browse_count": "",
					"total_money": "",
					"certified": "",
					"nickname": "",
					"is_pay_password": "",
					"follow_count": "",
					"is_close": "",
					"lastid": "",
					"userlevel_name": "",
					"age": "",
					"xq_name": "",
					/** sex【性别】 **/
					"sex": "",
					"name": ""
				},
				/** sex【性别】 **/
				"sex": "",
				"sex_options": [{
					"name": "保密",
					"value": "0",
					"image": ""
				}, {
					"name": "男",
					"value": "1",
					"image": ""
				}, {
					"name": "女",
					"value": "2",
					"image": ""
				}],
				"header_img": "",
				xb:'',//性别
				group:'',//1学生  2教师
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			this.group=uni.getStorageSync('USER_GROUP')
			this.queryUserInfoFunc()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.group=uni.getStorageSync('USER_GROUP')
			// 获取校区的
			
			this.getke8478b189b32dFunc()

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			async getke8478b189b32dFunc() {
				if(this.group ==1){
					return
				}
				let dataxginfo = await this.$api.get(global.apiUrls.post68478b189b32d, {

				});

				if (dataxginfo.data.code != 1) {
					this.$message.info(dataxginfo.data.msg);
					return
				}
				let infoxginfo = dataxginfo.data;
				this.csinfo = infoxginfo.data
			},
			//获取用户详细信息
			async queryUserInfoFunc() {
				let url=this.group==1?global.apiUrls.post5c78c4772da97:host+'/api/v1/5c78c4772da97'
				let datauserInfo = await this.$api.get(url, {
					user_id: uni.getStorageSync('USER_INFO_7863').aid
				});

				if (datauserInfo.data.code != 1) {
					this.$message.info(datauserInfo.data.msg);
					return
				}
				let infouserInfo = datauserInfo.data;
				this.user = infouserInfo.data
				this.header_img = this.user.avatar
				console.log(this.header_img)
				if(this.group==1){
					this.xb=this.user.gender
					if (this.user.gender == 0) {
						this.sex = '保密';
					} else if (this.user.gender == '1') {
						this.sex = '男';
					} else if (this.user.gender == '2') {
						this.sex = ' 女';
					}
					return
				}
				this.xb=this.user.sex
				if (this.user.sex == 0) {
					this.sex = '保密';
				} else if (this.user.sex == '1') {
					this.sex = '男';
				} else if (this.user.sex == '2') {
					this.sex = ' 女';
				}
				
			},
			//修改个人资料
			async submitsFunc() {
				//请求方法
				//数据验证
				let obj = {
					avatar: this.header_img,
					nickname: this.user.nickname,
					sex: this.xb
				}
				console.log(obj)
				// return
				let urls=this.group==1?global.apiUrls.post5cb54af125f1c:host+'/api/v1/5cb54af125f1c'
				let data5cb54af125f1c = await this.$api.post(urls, {
					avatar: this.header_img,
					nickname: this.group==1?this.user.real_name:this.user.nickname,
					sex: this.xb,
					gender:this.xb,
				});
				if (!data5cb54af125f1c) return
				if (data5cb54af125f1c.data.code != 1) {
					this.$message.info(data5cb54af125f1c.data.msg);
					return
				}
				let info5cb54af125f1c = data5cb54af125f1c.data;


				this.$message.info('修改成功');
				setTimeout(function() {
					uni.navigateBack()
				}, 800);
				
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;

		.personalData_flex_3_higd {
			width: 100%;
			background: rgba(255, 255, 255, 1);
			background-size: 100% auto;
			padding: 0rpx 32rpx 0rpx 32rpx;

			.personalData_fd3_0_higd {
				border-bottom: 1px solid #eee;
				height: 125rpx;
				width: 100%;

				.personalData_fd3_0_c1_c0_higd {
					color: var(--benbenFontColor1);
					font-size: 32rpx;
					text-align: right;
				}

				.personalData_fd3_0_c1_c0_1_higd {
					color: var(--benbenFontColor0);
					font-size: 32rpx;
					text-align: right;
				}

				.personalData_fd3_0_c1_c1_higd {
					width: 22rpx;
					height: 32rpx;
					margin: 0rpx 0rpx 0rpx 16rpx;
				}
			}
		}

		.personalData_fd3_0_c0_higd {
			font-size: 32rpx;
			font-weight: 400;
			color: #333333;
			line-height: 45rpx;
		}

		.personalData_fd3_1_higd {
			height: 125rpx;
			border-bottom: 1px solid #eee;
			width: 100%;
		}

		.personalData_fd3_1_c1_higd {
			color: var(--benbenFontColor0);
			font-size: 32rpx;
			font-weight: 400;
			line-height: 45rpx;
		}

		.personalData_picker2_0_higd {
			padding: 0rpx 32rpx 0rpx 32rpx;
			line-height: 88rpx;
			border-radius: 25rpx 25rpx 0rpx 0rpx;
			border-bottom: 1px solid #eee;
			background: #fff;
			background-size: 100% auto !important;

			.personalData_picker2_0_c0_higd {
				font-size: 28rpx;
				color: var(--benbenFontColor2);
			}

			.personalData_picker2_0_c1_higd {
				font-size: 32rpx;
				color: var(--benbenFontColor1);
			}

			.personalData_picker2_0_c2_higd {
				color: #D32A29;
				font-size: 28rpx;
			}
		}

		.personalData_flex_1_higd {
			background: #fff;
			padding: 0rpx 32rpx 0rpx 32rpx;
			margin: 0rpx 0rpx 16rpx 0rpx;

			.personalData_fd1_0_higd {
				border-bottom: 1px solid #eee;
				height: 152rpx;

				.personalData_fd1_0_c1_higd {
					width: 96rpx;
					height: 96rpx;
					border-radius: 50rpx 50rpx 50rpx 50rpx;
					margin: 0rpx 0rpx 0rpx auto;

					.personalData_fd1_0_c1_image_higd {
						width: 96rpx;
						height: 96rpx;
						border-radius: 48rpx;
					}
				}

				.personalData_fd1_0_c2_higd {
					width: 22rpx;
					height: 32rpx;
					margin: 0rpx 0rpx 0rpx 16rpx;
				}
			}

			.personalData_fd1_1_higd {
				border-bottom: 1px solid #eee;
				height: 125rpx;

				.personalData_fd1_1_c1_higd {
					text-align: right;
					font-size: 32rpx;
					font-weight: 400;
					color: var(--benbenFontColor0);
					margin: 0rpx 0rpx 0rpx 24rpx;
				}
			}

			.personalData_fd1_2_higd {
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				font-size: 32rpx;
				background: #D32A29;
				color: var(--benbenFontColor3);
				line-height: 88rpx;
				height: 88rpx;
				margin: 45rpx 0rpx 45rpx 0rpx;
				position: absolute;
				width: 686rpx;
				bottom: 0rpx;
			}
		}

		.personalData_fd1_0_c0_higd {
			font-size: 32rpx;
			font-weight: 400;
			color: #333333;
			line-height: 45rpx;
		}

		.personalData_flex_0_higd {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			z-index: 10;
			top: 0rpx;
			background: #fff;
			background-size: 100% auto !important;

			.personalData_fd0_0_higd {
				padding: 0rpx 32rpx 0rpx 32rpx;

				.personalData_fd0_0_c1_c0_higd {
					font-size: 36rpx;
					font-weight: 700;
					color: #333;
					line-height: 88rpx;
				}
			}
		}

		.personalData_fd0_0_c0_higd {
			width: 120rpx;

			.personalData_fd0_0_c0_c0_higd {
				font-size: 36rpx;
				color: #333;
			}
		}
	}
</style>
